package twentytwenty;

/**
 * @Author: Spider Man
 * @Description:
 * @Date Created in 2020-09-22 10:09
 * @Modified By:
 */
public class RemoveElement_27 {
    public static void main(String[] args) {
        int [] nums = new int[]{1,1,1,2,11,1};
        System.out.println(removeElement(nums,1));
    }

    public static int removeElement(int[] nums, int val) {
        int count = 0;
        for (int j = 0; j < nums.length; j++) {
            if (nums[j] != val) {
                nums[count] = nums[j];
                count++;
            }
        }
        return count;
    }
}
